package com.project.bookstore.book.service;

import com.project.bookstore.book.entity.BookIndex;
import com.project.bookstore.book.pojo.BookIndexVO;
import com.project.bookstore.book.pojo.BookMultiConditionVO;
import com.project.bookstore.book.entity.Book;
import com.baomidou.mybatisplus.extension.service.IService;
import com.project.bookstore.book.pojo.BookDetailVO;
import com.project.bookstore.book.pojo.BookNameByKeyWordVO;
import com.project.bookstore.common.CommonResult;

import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;

/**
* @author 12603
* @description 针对表【book】的数据库操作Service
* @createDate 2022-04-17 17:06:34
*/
public interface BookService extends IService<Book> {

    CommonResult<List<BookMultiConditionVO>> getByMultiCondition(BookMultiConditionVO multiConditionVO);

    int insert(BookDetailVO bookDetailVO);

    int deleteBookDetailById(Long id);

    CommonResult<Void> updateBookDetailById(BookDetailVO bookDetailVO);

    BookDetailVO getBookDetailById(Long id);

    CommonResult<Void> multiDisEnableByIds(Long[] ids);

    CommonResult<Void> multiEnableByIds(Long[] ids);

    CommonResult<Void> multiDisMarketableByIds(Long[] ids);

    CommonResult<Void> multiMarketableByIds(Long[] ids);

    BookDetailVO getByBookName(String bookName);

    List<BookNameByKeyWordVO> getBookNameByBookName(String bookName) ;

    /**
     * 根据 ID 数组 批量删除书籍
     * @param ids
     * @return
     */
    CommonResult<Void> multiDeleteByIds(Long[] ids);

    /**
     * 检查 map<bookId,count> 的库存是否足够
     * @param bookPCSMap
     * @return
     */
    boolean hasPCS(Map<Long, Integer> bookPCSMap);

    void updateSaleCountPCS(Map<Long, Integer> bookPCSMap);

    //首页书籍展示
    CommonResult<List<BookIndexVO>> getBooksForIndex();

    //通过类别ID说去书籍
    CommonResult<List<BookIndexVO>> getBooksByClassifyId(Long categoryId);

    //通过父类别ID查询书籍
    CommonResult<List<BookIndexVO>> getBooksByClassifyIdByParentId(Long parentId);
}
